package com.freight.order.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.freight.core.common.utils.PageUtil;
import com.freight.core.common.utils.ResultUtil;
import com.freight.core.common.vo.PageVo;
import com.freight.core.common.vo.Result;
import com.freight.order.dto.AreaPcDto;
import com.freight.order.dto.CompanyGoodsDto;
import com.freight.order.dto.DriverGoodsDto;
import com.freight.order.service.IOrderMainMapperService;
import com.freight.order.vo.CompanyGoodsVo;
import com.freight.order.vo.DriverGoodsVo;
import com.freight.order.vo.PlatformGoodsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@Api(description = "货源信息获取列接口")
@RequestMapping("/freight/orderAppointVo")
@Transactional
public class OrderMainController {

    @Autowired
    private IOrderMainMapperService iOrderMainMapperService;


    @RequestMapping(value = "/getCompanyGoodInfo", method = RequestMethod.POST)
    @ApiOperation(value = "货主端 --- 配货大厅，获取货源列表")
    public Result<IPage<CompanyGoodsVo>> getCompanyGoodInfoByPage(PageVo page, CompanyGoodsDto companyGoodsDto) {
        Page<CompanyGoodsVo> data = iOrderMainMapperService.getCompanyGoodsInfo(PageUtil.initMpPage(page), companyGoodsDto);
        return new ResultUtil<IPage<CompanyGoodsVo>>().setData(data);
    }


    @RequestMapping(value = "/quotationTrack", method = RequestMethod.POST)
    @ApiOperation(value = "货主端 --- 报价跟踪")
    public Result<IPage<CompanyGoodsVo>> quotationTrack(PageVo page, CompanyGoodsDto companyGoodsDto) {
        Page<CompanyGoodsVo> data = iOrderMainMapperService.quotationTrack(PageUtil.initMpPage(page), companyGoodsDto);
        return new ResultUtil<IPage<CompanyGoodsVo>>().setData(data);
    }


    @RequestMapping(value = "/getGoodsDetails", method = RequestMethod.POST)
    @ApiOperation(value = "获取货源详情 -----")
    public Result<PlatformGoodsVo> getGoodsDetails(Long goodsid) {
        PlatformGoodsVo data = iOrderMainMapperService.getGoodsDetails(goodsid);
        return new ResultUtil<PlatformGoodsVo>().setData(data);
    }

    @RequestMapping(value = "/getQuotedorderGoods", method = RequestMethod.POST)
    @ApiOperation(value = "司机端 --- 获取司机已报价货源")
    public Result<IPage<DriverGoodsVo>> getQuotedorderGoods(PageVo page, DriverGoodsDto driverGoodsDto) {
        Page<DriverGoodsVo> data = iOrderMainMapperService.getQuotedorderGoods(PageUtil.initMpPage(page), driverGoodsDto);
        return new ResultUtil<IPage<DriverGoodsVo>>().setData(data);
    }

    @RequestMapping(value = "/getDriverGoodInfo", method = RequestMethod.POST)
    @ApiOperation(value = "司机端 --- 获取货源大厅列表")
        public Result<IPage<DriverGoodsVo>> getDriverGoodInfo(PageVo page, DriverGoodsDto driverGoodsDto) {
        Page<DriverGoodsVo> data = iOrderMainMapperService.getDriverGoodsInfo(PageUtil.initMpPage(page), driverGoodsDto);
        return new ResultUtil<IPage<DriverGoodsVo>>().setData(data);
    }

    @RequestMapping(value = "/getPcDriverGoodInfoByPage", method = RequestMethod.POST)
    @ApiOperation(value = "PC端 --- 获取货源管理列表 -----")
    public Result<IPage<PlatformGoodsVo>> getPcDriverGoodInfoByPage(PageVo page, AreaPcDto areaPcDto) {
        Page<PlatformGoodsVo> data = iOrderMainMapperService.getPcDriverGoodInfoByPage(PageUtil.initMpPage(page), areaPcDto);
        return new ResultUtil<IPage<PlatformGoodsVo>>().setData(data);
    }


}
